<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title></title>
</head>
<body>
<%
	BinaryReader bReader = new BinaryReader(Request.InputStream);
  	string strTemp = System.Text.Encoding.GetEncoding("iso-8859-1").GetString(
  	bReader.ReadBytes((int)bReader.BaseStream.Length), 0, (int)bReader.BaseStream.Length);
  	string match = "Content-Type: application/msword\r\n\r\n";
  	int pos = strTemp.IndexOf(match) + match.Length;
  	bReader.BaseStream.Seek(pos, SeekOrigin.Begin);

 	 string newFile = Server.MapPath(".") + "\\MyFile2.doc";
  	FileStream newDoc = new FileStream(newFile, FileMode.Create, FileAccess.Write);
  	BinaryWriter bWriter = new BinaryWriter(newDoc);
  	bWriter.BaseStream.Seek(0, SeekOrigin.End);


 	 while (bReader.BaseStream.Position < bReader.BaseStream.Length - 38)
 	 bWriter.Write(bReader.ReadByte());

 	bReader.Close();
 	 bWriter.Flush();
  	bWriter.Close();
%>
</body>
</html>
